<template>
    <el-dialog
        title="确认一下收费信息"
        :visible.sync="dialogVisible"
        width="30%"
        :before-close="handleClose"
    >
        <span>支付金额：￥ {{totalAmount}}</span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="$router.go(-1)">取 消</el-button>
            <el-button type="primary" @click="topay(totalAmount)"
                >立即支付</el-button
            >
        </span>
    </el-dialog>
</template>

<script>
import {alipay} from '../api/api'
export default {
    data() {
        return {
            dialogVisible: true,
        };
    },
    props:['totalAmount'],
    methods: {
        handleClose(done) {
            this.$confirm("确认关闭？")
                .then((_) => {
                    // console.log(done);
                })
                .catch((_) => {});
        },
        async topay(totalAmount){
            // console.log(totalAmount);
            const result=await alipay({totalAmount});
            console.log(result);
            window.location.href=result.data;
        }
    },
    
};
</script>